package com.javacoo.junit.generator.config.xml;

import java.io.InputStream;

import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;

import com.javacoo.junit.generator.constant.Constants;
/**
 * ParserEntityResolver
 * <li></li>
 * @author duanyong@jccfc.com
 * @date 2020/12/31 17:00
 */
public class ParserEntityResolver implements EntityResolver {

    public ParserEntityResolver() {
        super();
    }

    @Override
    public InputSource resolveEntity(String publicId, String systemId) {
        if (Constants.JUNIT_GENERATOR_CONFIG_PUBLIC_ID
                .equalsIgnoreCase(publicId)) {
            InputStream is = getClass()
                .getClassLoader()
                    .getResourceAsStream(
                            "com/javacoo/junit/generator/config/xml/junit-generator-config_1_0.dtd");
            return new InputSource(is);
        } else {
            return null;
        }
    }
}
